import { Routes, Route } from 'react-router-dom'
import { ThemeProvider } from './contexts/ThemeContext'
import AuthGuard from './components/AuthGuard'
import AdminLayout from './layouts/AdminLayout'
import Dashboard from './pages/admin/Dashboard'
import Users from './pages/admin/Users'
import Settings from './pages/admin/Settings'
import TestPage from './pages/admin/TestPage'
import Login from './pages/Login'
import Register from './pages/Register'
import Board from './board'
import './App.css'

function App() {
  return (
    <ThemeProvider>
      <Routes>
        {/* 默认路径 - 直接显示仪表盘页面 */}
        <Route path="/" element={
          <AuthGuard>
            <AdminLayout />
          </AuthGuard>
        }>
          <Route index element={<Dashboard />} />
          <Route path="dashboard" element={<Dashboard />} />
          <Route path="users" element={<Users />} />
          <Route path="settings" element={<Settings />} />
          <Route path="test" element={<TestPage />} />
        </Route>

        {/* 首页路由 - 后台管理页面 */}
        <Route path="/home" element={
          <AuthGuard>
            <AdminLayout />
          </AuthGuard>
        }>
          <Route index element={<Dashboard />} />
          <Route path="dashboard" element={<Dashboard />} />
          <Route path="users" element={<Users />} />
          <Route path="settings" element={<Settings />} />
          <Route path="test" element={<TestPage />} />
        </Route>

        {/* 管理后台路由 - 需要认证 */}
        <Route path="/admin" element={
          <AuthGuard>
            <AdminLayout />
          </AuthGuard>
        }>
          <Route index element={<Dashboard />} />
          <Route path="dashboard" element={<Dashboard />} />
          <Route path="users" element={<Users />} />
          <Route path="settings" element={<Settings />} />
        </Route>
        <Route path="/login" element={<Login />} />
        <Route path="/register" element={<Register />} />
        <Route path="/board" element={<Board />} />
      </Routes>
    </ThemeProvider>
  )
}

export default App
